package Day4_ClassAndArrayList;

import java.util.ArrayList;
import java.util.Scanner;

public class homeWork {

    public static void main(String[] args) {
        ArrayList<student> array = new ArrayList<>();

        student s1 = new student();
        s1.name = "kiana";
        s1.age = 18;
        s1.StudentNumber = 200301;

        student s2 = new student();
        s2.name = "broniya";
        s2.age = 18;
        s2.StudentNumber = 200302;

        array.add(s1);
        array.add(s2);

        Scanner sc = new Scanner(System.in);

        while (true) {
            System.out.println("请输入对应的数字选择对应的操作：");
            System.out.println("1.新增；2，更新年龄；3.展示数据；4.查找；5.退出");
            int num = sc.nextInt();
            sc.nextLine();
            if (num == 1) {
                student stu = new student();
                System.out.println("请输入要新增的姓名：");
                stu.name = sc.nextLine();
                System.out.println("请输入要新增的年龄：");
                stu.age = sc.nextInt();
                System.out.println("请输入要新增的学号：");
                stu.StudentNumber = sc.nextInt();
                array.add(stu);
            } else if ( num == 2 ) {
                System.out.println("不会，看不懂题目");
            } else if ( num == 3 ) {
                System.out.println("姓名        年龄        学号");
                for (int i = 0; i < array.size(); i++) {
                    System.out.println(array.get(i).name + "       " + array.get(i).age + "       " + array.get(i).StudentNumber);
                }
            } else if ( num == 4 ) {
                System.out.println("请输入要查找的学号：");
                int sum = sc.nextInt();
                for (int i = 0; i < array.size(); i++) {
                    if ( array.get(i).StudentNumber == sum ) {
                        System.out.println("姓名        年龄        学号");
                        System.out.println(array.get(i).name + "       " + array.get(i).age + "       " + array.get(i).StudentNumber);
                        break;
                    }
                }
            } else if ( num == 5 ) {
                break;
            }

        }
    }


}
